﻿using Comm100.Framework.Domain.Repository;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Bot.Domain.Entities;
using Bot.Domain.Interfaces;
using Bot.Domain.Bo;
using Castle.Windsor;
using Bot.Domain.Specifications;

namespace Bot.Domain.Categories.Service
{
    public class SmartTriggerActionSelectedAgentDomainService : ISmartTriggerActionSelectedAgentDomainService
    {
        private IWindsorContainer _container;
        private readonly IRepository<Guid, SmartTriggerActionSelectedAgent> _repository;

        public SmartTriggerActionSelectedAgentDomainService(IRepository<Guid, SmartTriggerActionSelectedAgent> repository, IWindsorContainer container)
        {
            this._repository = repository;
            this._container = container;
        }

        public SmartTriggerActionSelectedAgent Create(SmartTriggerActionSelectedAgent category)
        {
            return _repository.Create(category);
        }

        public SmartTriggerActionSelectedAgent Get(Guid id)
        {
            return _repository.Get(id);
        }

        public SmartTriggerActionSelectedAgent Update(SmartTriggerActionSelectedAgentUpdateBo bo)
        {
            SmartTriggerActionSelectedAgent smartTriggerActionSelectedAgent = _repository.Get(bo.Id);
            smartTriggerActionSelectedAgent.Id = bo.Id;
            smartTriggerActionSelectedAgent.SmartTriggerActionId = bo.SmartTriggerActionId;
            smartTriggerActionSelectedAgent.AgentId = bo.AgentId;

            _repository.Update(smartTriggerActionSelectedAgent);

            return smartTriggerActionSelectedAgent;

        }

        public IEnumerable<SmartTriggerActionSelectedAgent> List()
        {
            return _repository.ListAll();
        }

        public IEnumerable<SmartTriggerActionSelectedAgent> GetByActionId(Guid actionId)
        {
            return _repository.List(new SmartTriggerActionSelectedAgentFilterSpecification(actionId));
        }

        public void Delete(Guid id)
        {
            SmartTriggerActionSelectedAgent smartTriggerActionSelectedAgent = _repository.Get(id);

            _repository.Delete(smartTriggerActionSelectedAgent);

        }
    }
}
